import pop_ui_base from '../../common/ui/pop_ui_base'
import EventDispatch, { Event_Name } from '../../common/event/EventDispatch'
import Model from '../Model';
import {AudioPlayer} from '../../common/audio/AudioPlayer'
import {AUDIO_CONFIG} from '../../service/Constant'

const {ccclass, property} = cc._decorator;

@ccclass
export default class ResultControl extends pop_ui_base {

    @property(cc.Label)
    score: cc.Label = null;

    @property(cc.Sprite)
    sp1: cc.Sprite = null;

    constructor() {
        super();
    }

    on_show() {
        this.score.string =  Model.ins().score + ''
        cc.tween(this.sp1.node)
        .to(0, {position: cc.v3(0, 300, 0)})
        .by(1, {position: cc.v3(0, -80, 0), opacity: 255})
        .start()

        AudioPlayer.ins().play_sound(AUDIO_CONFIG.Audio_fail)
    }

    back () {
        super.hide()
        EventDispatch.ins().fire(Event_Name.GO_HOME);
    }

    relive() {
        super.hide()
        EventDispatch.ins().fire(Event_Name.GAME_RELIVE)
    }
    // update (dt) {}
}
